package com.example.config;

import com.example.interceptor.SSOInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

//    获取loginInterceptor拦截器对象
    @Bean
    public SSOInterceptor getLoginInterceptor(){
        return new SSOInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("拦截器启动");
        // 将loginInterceptor拦截器对象注册到InterceptorRegistry对象中
        registry.addInterceptor(getLoginInterceptor())
                .addPathPatterns("/blockchain/api/dataList", "/autoregister","/trace","/data","/addbigfile","/getbigfile","/details","/log","/traceFromSource","/tracePath","/gettracefile"); //只拦截/blockchain/api/dataList接口
    }
}
